<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="./../layui/css/layui.css" media="all">
    <script src="./../layui/layui.js"></script>
    <script src="./../js/jquery-1.8.3.min.js"></script>
    <script src="./../js/jQuery.md5.js"></script>
    <script src="./../js/env.js"></script>

    <title>管理员修改密码</title>
    <style>
        .signin {
            margin: 0 auto;
            text-align: center;
            margin-top: 200px;
        }

        .signin h1 {
            text-align: center;
            padding-bottom: 10px;
        }

        .layui-btn {
            width: 300px;
        }

        .layui-input-block {
            width: 300px;
            margin: 0 auto;
        }
    </style>
</head>


<body>
<div class="signin-p">
    <div class="signin">
        <h1>修改密码</h1>
        <form class="layui-form" action="">
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <input type="password" id="oldpassword" required lay-verify="required" placeholder="请输入旧密码"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <input type="password" id="newpassword" required lay-verify="required" placeholder="请输入新密码"
                           autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-filter="formDemo" onclick="submission()" type="button">提交</button>
                </div>
            </div>
        </form>
    </div>
</div>
</body>

</html>
<script>
    if (layui.sessionData('user').userInfo === undefined) {
        window.location.href = "../html/login.html"
    }
    //Demo
    layui.use('form', function () {
        var form = layui.form;

    });

    function submission() {
        var account = layui.sessionData('user').userInfo.account;
        var requestData = {
            "id": layui.sessionData('user').userInfo.id,
            "oldPassword": $.md5(account + "*" + $("#oldpassword").val()),
            "newPassword": $.md5(account + "*" + $("#newpassword").val())
        };
        var responseData = MyAjax("POST", "/admin/user/updateAdminPassword", requestData, getToken())
        if (responseData.code === 0) {
            layer.msg("操作成功");
            window.location.href = "../html/login.html";
        }

    }


</script>